<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>重新审核</title>
    <link href="../../css/admin/style.css" rel="stylesheet" type="text/css" />
    <script src="../../js/jquery-1.8.3.min.js" type="text/javascript"></script >
    <script src="../../js/ajaxfileupload.js" type="text/javascript"></script>
    <script src="../../js/ckeditor/ckeditor.js" type="text/javascript"></script >
    <script src="../../js/ckfinder/ckfinder.js" type="text/javascript"></script>
    <script>
        var id = location.search.split("=")[1];
        $("#id").val(id);
        $(function (res) {
            editor = CKEDITOR.replace("content");
            CKFinder.setupCKEditor(editor, '../../js/ckfinder');
            $.get("../../journalism/getjournalism",{id:id},function (res){
                if (res.code == 202){
                    window.parent.location.replace("../login.html");
                }else if (res.code == 500){
                    alert(res.msg);
                }else {
                    if (res.data[0].user == null){
                        var imgsrc =  "http://127.0.0.1:8080/userImg/"+res.data[0].writer.account+"/"+res.data[0].coverimage;
                    }else {
                        var imgsrc =  "http://127.0.0.1:8080/userImg/"+res.data[0].user.account+"/"+res.data[0].coverimage;
                    }
                    $("#title").val(res.data[0].title);
                    $("#summary").val(res.data[0].summary);
                    if (res.data[0].user == null){
                        $("#account").val(res.data[0].writer.account);
                    }else {
                        $("#account").val(res.data[0].user.account);
                    }
                    $("#coverimage").attr("src", imgsrc);
                    $("#journame").val(res.data[0].newstype.journame);
                    editor.setData(res.data[0].content);
                    var state1 = ""
                    if (res.data.state == 0) {
                        state1 += "保存"
                    } else if (res.data.state == 1) {
                        state1 += "未审核"
                    } else if (res.data.state == 2) {
                        state1 += "审核通过"
                    } else if (res.data.state == 3) {
                        state1 += "审核不通过"
                    }
                    $("#state").val(state1);
                }
            })
        })

        /*返回*/
        function goback(){
            location.assign("failExamine.html");
        }
        /*通过审核*/
        function passcheck(state){
            $.get("../../journalism/passcheck",{id:id,state:state},function (res){
                if (res.code == 202){
                    window.parent.location.replace("../login.html");
                }else if (res.code == 500){
                    alert(res.msg);
                }else {
                    alert(res.mag);
                    location.assign("failExamine.html");
                }
            })
        }
    </script>
</head>
<body>
<form id="formId">
    <input type="hidden" id="id" name="id">
    <div class="formbody">
        <div class="formtitle"><span>基本信息</span></div>
        <ul class="forminfo">

            <li>
                <label>标题</label>
                <input id="title" name="title" type="text" class="dfinput" />
            </li>
            <li>
                <label>摘要</label>
                <input id="summary" name="summary" type="text" class="dfinput" />
            </li>
            <li>
                <label>发布人</label>
                <input id="account" name="account" type="text" class="dfinput" />
            </li>
            <li>
                <label>封面图</label>
                <img src="" id="coverimage" width="80px" height="40px">
            </li>
            <li>
                <label>新闻类型</label>
                <input id="journame" name="journame" type="text" class="dfinput" />
            </li>
            <li>
                <label>文章内容</label>
                <textarea cols="100" rows="40" id="content" name="content"></textarea>
            </li>
            <li>
                <label>状态</label>
                <input id="state" name="state" type="text" class="dfinput" />
            </li>
            <li>
                <input type="button" value="返回" onclick="goback()" />
                <input type="button" value="通过审核" onclick="passcheck(2)" />
            </li>
        </ul>
    </div>
</form>
</body>
</html>